package com.logistics.organization.entity.domain;

import com.baomidou.mybatisplus.annotation.IdType;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable;

import com.baomidou.mybatisplus.annotation.TableName;
import com.logistics.organization.entity.model.OrganizationSave;
import com.logistics.utils.tool.DateUtils;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * <p>
 * 
 * </p>
 *
 * @author zhiyu.fan
 * @since 2024-05-14
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("sys_organization")
public class Organization implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    private String name;

    private String code;

    private Integer parentId;

    private String type;

    private String wcCode;

    private String createOrgCode;

    private String createDepCode;

    private String creator;

    private Date createTime;

    private String updater;

    private Date updateTime;

    public static Organization build(OrganizationSave edit){
        Organization organization = new Organization();
        organization.setName(edit.getName());
        organization.setCode(edit.getCode());
        organization.setType(edit.getType());
        organization.setParentId(edit.getParentId());
        organization.setWcCode(edit.getWcCode());
        organization.setCreateDepCode(edit.getCreateDepCode());
        organization.setCreateOrgCode(edit.getCreateOrgCode());
        organization.setCreator(edit.getCreator());
        organization.setCreateTime(DateUtils.stringToDateFormat(edit.getCreateTime(), DateUtils.YYYY_MM_DD_HH_MM_SS));
        organization.setUpdater(edit.getUpdater());
        organization.setUpdateTime(DateUtils.stringToDateFormat(edit.getUpdateTime(), DateUtils.YYYY_MM_DD_HH_MM_SS));
        return organization;
    }
}
